﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

namespace ApiTest.App_Start
{
    public class MyDelegateHanlder:DelegatingHandler
    {
        protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var contenttype = request.Content.Headers.ContentType;
            var media = contenttype.MediaType;
            switch (media)
            {
                case "application/json":
                    {
                     var stream=  await request.Content.ReadAsStreamAsync();
                    }
                    break;
                case "application/x-www-form-urlencoded":
                    {
                        var query = await request.Content.ReadAsStringAsync();
                        
                    }
                    break;
                case "multipart/form-data":

                    break;
                default:
                    break;
            }
            return await base.SendAsync(request, cancellationToken);
        }
    }
}